
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>家居家具管理系统</title>

    <!-- begin::global styles -->
    <link rel="stylesheet" href="${APP_PATH}/assets/vendors/bundle.css" type="text/css">
    <!-- end::global styles -->



    <!-- begin::custom styles -->
    <link rel="stylesheet" href="${APP_PATH}/assets/css/app.css" type="text/css">
    <link rel="stylesheet" href="${APP_PATH}/assets/css/custom.css" type="text/css">
    <!-- end::custom styles -->

</head>
<body>

<!-- begin::page loader-->
<div class="page-loader">
    <div class="page-loader">
        <div class="spinner-border text-info"></div>
        <span>加载中 ...</span>
    </div>
</div>
<!-- end::page loader -->

<!-- begin::navigation -->
<jsp:include page="/WEB-INF/jsps/Manager/common/navigation.jsp"/>
<!-- end::navigation -->

<!-- begin::top -->
<jsp:include page="/WEB-INF/jsps/Manager/common/top.jsp"/>
<!-- end::top -->

<!-- begin::main content -->
<main class="main-content">

    <div class="container-fluid">

        <!-- begin::page header -->
        <div class="page-header d-md-flex justify-content-between align-items-center">
            <h4>我的订单</h4>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb m-t-0">
                    <li class="breadcrumb-item"><a href="${APP_PATH}/toManager">首页</a></li>
                    <li class="breadcrumb-item active" aria-current="page">我的订单</li>
                </ol>
            </nav>
        </div>
        <!-- end::page header -->


        <div class="card">
            <div class="card-body">
                <ul class="nav nav-tabs m-b-30" id="myTab" role="tablist">
                    <li class="nav-item">
                        <a id="allOrder" class="nav-link active" data-toggle="tab" href="#all" role="tab" aria-controls="all"
                           aria-selected="true"><span>全部订单</span><span id="allOrderBadge" style="margin-left: 5px;" class="badge badge-primary"></span></a>
                    </li>
                    <li class="nav-item">
                        <a id="readyOrder" class="nav-link" data-toggle="tab" href="#ready" role="tab" aria-controls="ready"
                           aria-selected="false"><span>待发货订单</span><span id="readyOrderBadge" style="margin-left: 5px;" class="badge badge-danger"></span></a>
                    </li>
                    <li class="nav-item">
                        <a id="sendOrder" class="nav-link" data-toggle="tab" href="#send" role="tab" aria-controls="send"
                           aria-selected="false"><span>已发货订单</span><span id="sendOrderBadge" style="margin-left: 5px;" class="badge badge-info"></span></a>
                    </li>
                    <li class="nav-item">
                        <a id="finishOrder" class="nav-link" data-toggle="tab" href="#finish" role="tab" aria-controls="finish"
                           aria-selected="false"><span>已完成订单</span><span id="finishOrderBadge" style="margin-left: 5px;" class="badge badge-success"></span></a>
                    </li>
                </ul>


                <div class="tab-content" id="myTabContent">
                    <div class="tab-pane fade show active" id="all" role="tabpanel" aria-labelledby="home-tab">
                        <jsp:include page="/WEB-INF/jsps/Manager/myOrders/allOrder.jsp"/>
                    </div>
                    <div class="tab-pane fade" id="ready" role="tabpanel" aria-labelledby="profile-tab">
                        <jsp:include page="/WEB-INF/jsps/Manager/myOrders/readyOrder.jsp"/>
                    </div>
                    <div class="tab-pane fade" id="send" role="tabpanel" aria-labelledby="contact-tab">
                        <jsp:include page="/WEB-INF/jsps/Manager/myOrders/sendOrder.jsp"/>
                    </div>
                    <div class="tab-pane fade" id="finish" role="tabpanel" aria-labelledby="contact-tab">
                        <jsp:include page="/WEB-INF/jsps/Manager/myOrders/finishOrder.jsp"/>
                    </div>
                </div>

            </div>
        </div>



        <!-- begin::bottom -->
        <div class="card-group">
            <jsp:include page="/WEB-INF/jsps/Manager/common/bottom.jsp"/>
        </div>
        <!-- end::bottom -->

    </div>



</main>
<!-- end::main content -->


<!-- begin::global scripts -->
<script src="${APP_PATH}/assets/vendors/bundle.js"></script>
<!-- end::global scripts -->


<!-- begin::custom scripts -->
<script src="${APP_PATH}/assets/js/custom.js"></script>
<script src="${APP_PATH}/assets/js/app.js"></script>
<!-- end::custom scripts -->


</body>
</html>

<script>
    var orderTarget = null;
$(function () {
    $("#${requestScope.orderTarget}").click();
    $("#check").change(function () {
    $("input[name = 'oid']").prop("checked",$(this).prop("checked"));
    });

    $(".nav-link").each(function () {
        $(this).mouseleave(function () {
            getTarget();
        });
    });
});

    function getTarget() {
        orderTarget = $("#myTab a[class *= active]").attr("id");
    }

function deleteOrders() {
    var oids = new Array();
    $("input[name = 'oid']:checked").each(function () {
        oids.push($(this).val());
    });
    swal({
        title: "确定要删除吗?",
        icon: "warning",
        buttons: ["算了", "就要"],
        dangerMode: true
    }).then((willDelete) => {
        if (willDelete) {

        if(oids.length > 0){
            $.ajax({
                url : "${APP_PATH}/myOrders/deleteOrders",
                method : "POST",
                data : {
                    oids : oids
                },
                success : function (result) {
                    if(result.success){
                        swal("删除成功！", {
                                icon: "success"
                            });
                        OrderRenovate();
                    }
                }
            });
        }

        } else {
            swal("您取消了删除.", {
        icon: "info"
    });
}
});
}

function toOrderDetail(oid,pageNo) {
   window.location.href = '${APP_PATH}/toOrder_Detail?oid='+oid+"&orderTarget="+orderTarget+"&pageNo="+pageNo;
}

function deleteOrder(oid,otype) {
    if(otype == 2){
        swal({
            title: "确定要删除吗?",
            icon: "warning",
            buttons: ["算了", "就要"],
            dangerMode: true
        }).then((willDelete) => {
            if (willDelete) {

                $.ajax({
                    url: "${APP_PATH}/myOrders/deleteOrder",
                    method: 'POST',
                    data:{
                        oid : oid
                    },
                    success: function (result) {
                        if (result.success) {
                            swal("删除成功！", {
                                    icon: "success"
                                }
                            );
                            OrderRenovate();
                        }
                    }
                });

            } else {
                swal("您取消了删除.", {
            icon: "info"
        });
    }
    });
    }else{
        swal("该订单正在进行中，无法删除！", {icon: "error"});
    }
}

function OrderRenovate() {
    $("#Check").prop("checked",false);
    getAllOrder(allOrderPage);
    getReadyOrder(readyOrderPage);
    getSendOrder(sendOrderPage);
    getFinishOrder(finishOrderPage);
}
</script>


